surface: Hide chained autohiding popups together
authorJonas Ådahl <jadahl@gmail.com>
Sat, 18 Apr 2020 20:33:52 +0000 (22:33 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Sat, 18 Apr 2020 20:33:52 +0000 (22:33 +0200)
When we autohide a popup surface with a grab, hide all other auto hiding
popups up the popup chain. The end result is that when you click outside
a menu with submenus open, the whole menu chain is dismissed.

gdk/gdksurface.c

index 9f26ff828d1d264f05902dd03ee35766bc3c024c..6c8195523b023d4422be2b22959e980b76e9464f 100644 (file)
@@ -2783,6 +2783,18 @@ gdk_synthesize_surface_state (GdkSurface     *surface,
   gdk_surface_set_state (surface, (surface->state | set_flags) & ~unset_flags);
 }
 
+static void
+hide_popup_chain (GdkSurface *surface)
+{
+  GdkSurface *parent;
+
+  gdk_surface_hide (surface);
+
+  parent = surface->parent;
+  if (parent->autohide)
+    hide_popup_chain (parent);
+}
+
 static gboolean
 check_autohide (GdkEvent *event)
 {
@@ -2812,7 +2824,7 @@ check_autohide (GdkEvent *event)
           if (grab_surface != gdk_event_get_surface (event) &&
               grab_surface->autohide)
             {
-              gdk_surface_hide (grab_surface);
+              hide_popup_chain (grab_surface);
               return TRUE;
             }
         }